<template>
  <div style="height:100%;">
    <swiper  dots-position="center"  :aspect-ratio="scale/screenHeight" v-model="swiperItemIndex" >
      <swiper-item class="swiper-demo-img"  v-for="(item, index) in lists" :key="index"><img v-lazy="item.img" @click="chooseImg"></swiper-item>
    </swiper>

  </div>
</template>
<script type="application/ecmascript">
  import * as types from '@/vuex/types'
  import routers from '@/router'
  import { Swiper,Divider,SwiperItem,TransferDomDirective as TransferDom } from 'vux'
  const baseList = [{
    url: 'javascript:',
    img: 'https://static.vux.li/demo/1.jpg',
    title: '送你一朵fua'
  }, {
    url: 'javascript:',
    img: 'https://static.vux.li/demo/2.jpg',
    title: '送你一辆车'
  }, {
    url: 'javascript:',
    img: 'https://static.vux.li/demo/1.jpg',
    title: '送你一次旅行',
    fallbackImg: 'https://static.vux.li/demo/3.jpg'
  }]
  const urlList = baseList.map((item, index) => ({
    img: item.img,
  }))
  export default {
    components: {
      Swiper,
      Divider,
      SwiperItem,
      TransferDom
    },
    name: 'chooseModule',
    data () {
      return {
        lists:urlList,
        lists_index:0,
        screenHeight: 160,//减去header的60px
        swiperItemIndex:1,
        scale:375
      }
    },
    mounted(){
      this.$store.commit(types.CHANGEMORE, false);
      this.$store.commit(types.ADDSTATUS, false);
      let initHeight = document.body.clientHeight-46-54
      this.screenHeight = initHeight
      //比例系数
      this.scale = initHeight*initHeight/document.body.clientWidth
      this.$store.commit(types.ROUTESTATES, 'choseModule');
    },
    computed:{
      // ...mapGetters({
      //   getDtatas:['listView/getDtatas']
      // }),
      // tabs(){
      //   return this.getDtatas
      // },
    },
    methods: {
      chooseImg(){
        const _this = this
         this.$vux.confirm.show({
           content: '您确定使用当前模板？',
           onConfirm () {
            let mid = _this.$store.state.listView.validaty
            let uid = _this.swiperItemIndex+1
            let models = '/Models'+mid+'_'+uid
            _this.$store.commit(types.CHOOSEMODELS, models);
            routers.push('/Models'+mid+'_'+uid)
           }
         }) 
      },
      getHeight(val){
        console.log(val)
      },
      onSwiperItemIndexChange(val){
      },
      onIndexChange (index) {
       this.lists_index = index
      }
    },
  }
</script>